import { useState } from "react";

//自定义钩子hook
const useMethods = () => {
  const [value, setValue] = useState(true);
  //导出
  return {
    value,
    setValue,
  };
};
const HookDemo = () => {
  //解构并导入
  const { value, setValue } = useMethods();
  return (
    <>
      <button onClick={() => setValue(!value)}>自定义Hook</button>
      {value && <div>你好hook</div>}
    </>
  );
};

export default HookDemo;
